package com.ktg.mes.rec.domain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.annotation.*;
import com.ktg.common.utils.StringUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;


/**
 * 工序项对象 rec_processes_ext
 *
 * @author byteco
 * @date 2022-11-04
 */

@Data
@Accessors(chain = true)
@TableName("rec_processes_ext")
public class RecProcessesExt extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 工序项id */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    /** 字段名称 */
    @Excel(name = "PDA字段名称")
    private String namePda;

    /** PDA排序 */
    @Excel(name = "PDA排序")
    private Integer orderPda;

    /** 字段说明 */
    @Excel(name = "字段说明")
    private String des;


    /** 是否必填字段（0-必填 1-不是必填） */
    @Excel(name = "PDA是否必填字段", readConverterExp = "0=-必填,1=-不是必填")
    private Long required;


    /** 字段类型 */
    @Excel(name = "PDA字段类型")
    private String type;


    /** 工序id */
    @Excel(name = "工序id")
    private Long processId;



    /** 后台参数名称 */
    @Excel(name = "后台参数名称")
    private String nameBackstage;


    /** 后台排序 */
    @Excel(name = "后台排序")
    private Integer orderBackstage;


    /** 后台是否必填 */
    @Excel(name = "后台是否必填")
    private Integer requireBackstage;


    /** 配置参数 */
    @Excel(name = "后台配置参数")
    private String ruleBackstage;

    /** 配置参数 */
    @Excel(name = "PDA配置参数")
    private String rulePda;


    public String jSONErrorString(){
        if (orderBackstage == null){
            orderBackstage = 0;
        }
        if(ruleBackstage != null && ruleBackstage.length() > 0){
            try{
                JSON json = (JSON) JSON.parse(ruleBackstage);
            }catch (Exception e){
                return "后台配置参数 JSON 不正确";
            }
        }else {
            ruleBackstage = "{}";
        }
        if(rulePda != null && rulePda.length() > 0){
            try{
                JSON json = (JSON) JSON.parse(rulePda);
            }catch (Exception e){
                return "PDA配置参数 JSON 不正确";
            }
        }else {
            rulePda = "{}";
        }
        return null;
    }



}
